package com.copa.l1491;

import java.math.BigDecimal;
import java.util.Arrays;

/**
 * @author copa
 * @createDate 2022-08-25 15:28
 * @function 直接取最值
 */
public class Test1 {

    public double average(int[] salary) {
        // 注意这个地方 必须用double 否则由于误差而解题错误
        double max = Arrays.stream(salary).max().getAsInt();
        // 注意这个地方 必须用double 否则由于误差而解题错误
        double min = Arrays.stream(salary).min().getAsInt();
        return (Arrays.stream(salary).sum() - max - min) / (salary.length - 2);
    }

    public static void main(String[] args) {
        int[] salary = {4000,3000,1000,2000};
        System.out.println(new Test1().average(salary));
    }
}
